#pragma once
#include <QWidget>
#include <QPixmap>

struct Line {
    int x1, y1, x2, y2;
};

class CanvasWidget : public QWidget
{
    Q_OBJECT
public:
    explicit CanvasWidget(QWidget *parent = nullptr);
    void parse(const QString &text);

public Q_SLOTS:
    void appendLine(const QString &text);

protected:
    void paintEvent(QPaintEvent *) override;

private:
    QString m_buffer;      // ← 保存所有要显示的文字
    QVector<Line> m_lines;
    QPixmap m_canvas;
};

